Skip to content

Conversation

@bergtholdt
Copy link
Contributor

Removed writing to the environment inside GUI loop.

Fixes #398

Makes #399 obsolete.

@bergtholdt bergtholdt mentioned this pull request Oct 1, 2019
@register_integration('qt', 'qt5')
def loop_qt5(kernel):
"""Start a kernel with PyQt5 event loop integration."""
os.environ['QT_API'] = 'pyqt5'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is not set, then there's no way to select the right Python bindings to create the event loop (unless users set QT_API by hand).

Therefore, I'm -1 on this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, changed it to set if unset. This also prevents it from being overwritten in every loop (as it was originally).

@ccordoba12
Copy link
Member

Ok, this is much better now, thanks! The only problem I see with this is that users still need to set QT_API='pyside2' by hand before running %gui qt5, even if PySide2 is the only Qt binding installed in your conda/virtual env.

@bergtholdt, do you think we could improve that situation?

@bergtholdt
Copy link
Contributor Author

OK I changed it to use pyqt5 as default and pyside2 as fall-back. That should not affect anything that worked before.

A little improvement, in the case that both backends are available, could be done to check if either module has been imported before calling %gui qt5 by checking sys.modules, but I would suspect that in that case the user sets the variable herself ("explicit is better than implicit").

@ccordoba12
Copy link
Member

A little improvement, in the case that both backends are available, could be done to check if either module has been imported before calling %gui qt5 by checking sys.modules, but I would suspect that in that case the user sets the variable herself ("explicit is better than implicit").

Ok, let's go with this simple approach for now and see how users respond to it.

@ivanov
Copy link
Member

ivanov commented May 15, 2021

Hey there, @bergtholdt, thank you for your contribution. I'm going through old PRs and this one has stalled.

I'm going to power cycle this one (close it and reopen it) just so we get the latest set of tests to rerun on it, and once I hear back on my the last remaining question to @ccordoba12 (or anyone else knowledgeable in QT stuff), then we can merge it.

@ivanov ivanov closed this May 15, 2021
@ivanov ivanov reopened this May 15, 2021
my interpretation of suggestion from @ccordoba12 and @stukowski
@ivanov ivanov added bug and removed needs-info labels Dec 3, 2021
@ivanov
Copy link
Member

ivanov commented Dec 3, 2021

@ccordoba12 and @stukowski - does 2d15ed6 look like I'm doing the thing you were talking about to keep with previous behavior? I'll wait to merge until I hear back or someone more competent shows up 😄

@ccordoba12
Copy link
Member

does 2d15ed6 look like I'm doing the thing you were talking about to keep with previous behavior?

Yeah, I think it does. I mean, it fallbacks to setting QT_API to pyqt5 if we fail to import PySide2, which should preserve the previous behavior at the very least.

So I'm ok with merging this one now.

@ivanov
Copy link
Member

ivanov commented Dec 3, 2021

Perfect, thank you, Carlos!

@ivanov ivanov merged commit ba29677 into ipython:master Dec 3, 2021
@ivanov
Copy link
Member

ivanov commented Dec 3, 2021

and thank you @bergtholdt for writing this up in the first place, apologies that it took so long to get merged in.

@ccordoba12
Copy link
Member

Perfect, thank you, Carlos!

No prob, and thanks to you for persevering until this PR was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

os.environ['QT_API'] gets overwritten in event-loop. No pyside2 integration.

4 participants